package com.exp.clickdemo.rl_bug;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

import androidx.annotation.Nullable;

import com.exp.clickdemo.R;

public class MyRelativeLayout extends RelativeLayout {
    public MyRelativeLayout(Context context) {
        this(context,null);
    }

    public MyRelativeLayout(Context context, @Nullable AttributeSet attrs) {
        this(context, attrs,0);
    }

    public MyRelativeLayout(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);

        LayoutInflater inflater = (LayoutInflater)   getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        inflater.inflate(R.layout.my_relativelayout, this);

       setOnClickListener(new OnClickListener() {
           @Override
            public void onClick(View v) {
                Log.i("xx", "click MyRelativeLayout");
            }
        });

        Log.i("xx", "MyRelativeLayout is clickable:" + isClickable());

        ImageView iv = findViewById(R.id.iv);
        iv.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.i("xx", "click ImageView");
            }
        });
    }
}
